package cuit.epoch.pymjl.security.controller;

import cuit.epoch.pymjl.security.common.result.Result;
import cuit.epoch.pymjl.security.entity.TMassage;
import cuit.epoch.pymjl.security.service.TMassageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class MessageController {
    final TMassageService tMassageService;
    @Autowired
    public MessageController(TMassageService tMassageService) {
        this.tMassageService = tMassageService;
    }
//    存入聊天数据
    @PostMapping("/addmassage")
    public Result addmassage(@RequestBody TMassage tMassage){
        boolean i = tMassageService.save(tMassage);
        return i==true?Result.suc("成功"):Result.fall("失败");
    }
    //获取时间
    @GetMapping("/getmassage")
    public Result getmassage(){
        List<TMassage> list = tMassageService.list();
        return Result.suc(list) ;
    }
}
